
from datetime import datetime
from typing import Union, Any, Optional, List

from pydantic import BaseModel, EmailStr, Field
from sqlalchemy import Boolean, Column, DateTime, ForeignKey, Integer, String, Text, UniqueConstraint
from sqlalchemy.orm import relationship
from sqlalchemy.sql import func
from sqlalchemy.schema import Sequence

#from app.common.database import Base
from app.models.base import TableBase


class IPWhiteList(TableBase):
    __tablename__ = "tr_ip_white_list"

    id = Column(Integer, primary_key=True, index=True)
    ip_addr = Column(String(24), unique=True, index=True, comment='IP地址')
    merc_no = Column(String(24), comment='商户编号')
    merc_name = Column(String(24), comment='商户名称')
    factor_no = Column(String(24), comment='代理编号')
    username = Column(String(24), comment='用户名')
    status = Column(Integer, comment='状态 1.启用 2.关闭')
    expire_time = Column(DateTime, comment='到期时间')
    target_system = Column(String(24), comment='目标系统')


class RiskRule(TableBase):
    __tablename__ = "tr_risk_rule"

    id = Column(Integer, primary_key=True, index=True)
    rule_code = Column(String(24), unique=True, index=True, comment='规则编码')
    rule_name = Column(String(24), comment='规则名称')
    category = Column(String(24), comment='规则类别 trans incoming')
    priority = Column(Integer, comment='规则优先级 1 2 3 4 默认0')
    status = Column(Integer, comment='状态 1.启用 2.关闭')
    rule_tpl = Column(Text, comment='规则模板')
    tpl_fmt = Column(String(24), comment='模板格式 1.json 2.yaml')
    fail_msg = Column(String(24), comment='失败信息')
    remark = Column(String(128), comment='规则描述')



